﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyVoteMVC.BackstageManagement.Views;
using MyVoteMVC.Service;
using MyVoteMVC.Common;
using MyVoteMVC.Data;
using MyVoteMVC.Domain;

namespace MyVoteMVC.BackstageManagement.Controllers
{
    public interface IWeeklyLotteryControl
    {
        void GetActivityList();
        void GetWeekLotteriesList(string activityID);
        void GetActivityUsersList(string activityID);
        void AddWeekLotteries(string activityID, string userID, string userEmail);
        void DeleteLotteries(string LotteriesID);
        
    }
    public class WeeklyLotteryControl : IWeeklyLotteryControl
    {   
        IActivityService activityService;
        IAuserService usersService;
        ILotteriesService lotteriesService;
        IWeeklylotteryView view;
        public WeeklyLotteryControl(IWeeklylotteryView view)
        {
            this.view = view;
            activityService = Factory.GetInstance<IActivityService>();
            usersService = Factory.GetInstance<IAuserService>();
            lotteriesService = Factory.GetInstance<ILotteriesService>();
        } 
        public void GetActivityList()
        {
            view.GetActivityListComplete(activityService.GetActivities());
        }
     
        public void GetActivityUsersList(string activityID)
        {
            view.GetActivityUsersComplete(activityService.GetUserJoinActivitesNoLottery(activityID));
        }

        public void GetWeekLotteriesList(string activityID)
        {
            view.GetWeekLotteriesComplete(lotteriesService.GetWeekLotteriesList(activityID));
        }

        public void AddWeekLotteries(string activityID, string userID, string userEmail)
        {
            string ticketID = "";
            VT_Tickets v_ticket = usersService.GetUersTickets(userID, activityID);
            if (v_ticket != null) ticketID = v_ticket.Ticket_ID;
            view.AddWeekLotteriesComplete(lotteriesService.AddWeekLotteries(activityID, ticketID, userEmail));
        }

        public void DeleteLotteries(string LotteriesID)
        {
            view.DeleteLotteriesComplete(lotteriesService.DeleteLotteries(LotteriesID));
        }
    
    }

}
